package com.cci.kangdao.ecjv.service.impl;

import com.cci.kangdao.dao.ECJVServiceStationMapper;
import com.cci.kangdao.ecjv.dto.ECJVServiceStationDto;
import com.cci.kangdao.ecjv.service.ECJVServiceStationService;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.DecimalFormat;
import java.util.List;

/**
 * @description: ecjv服务站信息
 * @author: 商伟
 * @company: CTY
 * @since: 2022/10/24 13:56
 * @version: V1.0
 **/
@Service
public class ECJVServiceStationServiceImpl implements ECJVServiceStationService {
    private Logger log = Logger.getLogger(this.getClass().getName());

    @Resource
    private ECJVServiceStationMapper ecjvServiceStationMapper;

    /**
     * 查询ecjv服务站信息
     * @param ecjvServiceStationDto
     * @return
     */
    @Override
    public List<ECJVServiceStationDto> getPageList(ECJVServiceStationDto ecjvServiceStationDto) {
        ecjvServiceStationDto.setPage((ecjvServiceStationDto.getPage()-1) * ecjvServiceStationDto.getPageSize());
        List<ECJVServiceStationDto> list = ecjvServiceStationMapper.getList(ecjvServiceStationDto);
        DecimalFormat df = new DecimalFormat("0.0");
        for(ECJVServiceStationDto dto : list){
            if(StringUtils.isNotBlank(dto.getDistance())){
                dto.setDistance(df.format(Double.parseDouble(dto.getDistance())));
            }
        }
        return list;
    }
}
